using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
	[DataObject(true)]
    public partial class ConfigurationController
    {
	
		public SqlDataProvider DataProvider { get; set; }

        public ConfigurationController()
        {
            DataProvider = new SqlDataProvider();
        }
	
		[DataObjectMethod(DataObjectMethodType.Insert, true)]
        public Guid InsertConfiguration(ConfigurationInfo oi)
		{
            return DataProvider.InsertConfiguration(oi.Name, oi.Description, oi.IsDefault);
		}

		[DataObjectMethod(DataObjectMethodType.Update, true)]
        public int UpdateConfiguration(ConfigurationInfo oi) 
		{
			return DataProvider.UpdateConfiguration(oi.ConfigurationId, oi.Name, oi.Description, oi.IsDefault);
		}
		
		[DataObjectMethod(DataObjectMethodType.Delete, true)]
        public int DeleteConfiguration(Guid configurationId)
		{
			return DataProvider.DeleteConfiguration(configurationId);
        }

		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public ConfigurationInfo SelectConfiguration(Guid configurationId)
        {    
			return ObjectFromDataRow(DataProvider.SelectConfiguration(configurationId));
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<ConfigurationInfo> SelectConfigurations()
		{
            return ListFromDataTable(DataProvider.SelectConfigurations());
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<ConfigurationInfo> SelectConfigurations(string sortExpression)
        {
            List<ConfigurationInfo> retList = SelectConfigurations();
            if (sortExpression.Length > 0)
            {
                retList.Sort(new ConfigurationComparer(sortExpression));
            }
            return retList;
        }

	}

}
		